
package uoc.biblioteca.struts.action;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

/**
 *
 * @author eswar@vaannila.com
 */
public class IdiomaAction extends DispatchAction {
    
   
    /**
     * This is the Struts action method called on
     * http://.../actionPath?method=myAction1,
     * where "method" is the value specified in <action> element : 
     * ( <action parameter="method" .../> )
     */
    public ActionForward cambiarIdioma(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
    	
    	String lang = "en";
    	
    	if(request.getParameter("id")!=null){
    		
    		
    		lang = request.getParameter("id");
    	}
    	
    	request.getSession().setAttribute(org.apache.struts.Globals.LOCALE_KEY,new Locale(lang)); //para struts
    	
    	return mapping.findForward("adquisicions");
    }
}